package com.wmc.service.impl;

import com.wmc.mapper.ClazzMapper;
import com.wmc.mapper.EmpMapper;
import com.wmc.mapper.StudentMapper;
import com.wmc.pojo.ClazzOption;
import com.wmc.pojo.Emp;
import com.wmc.pojo.JobOption;
import com.wmc.pojo.Student;
import com.wmc.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private StudentMapper studentMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = empMapper.countEmpJobData();

        List<Object> jobList = list.stream().map(dateMap -> dateMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dateMap -> dateMap.get("num")).toList();

        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpSexData() {
        return empMapper.countEmpGenderData();

    }

    @Override
    public List<Map<String, Object>> getStudentDegreeData() {
        return studentMapper.countStudentDegreeData();
    }

    @Override
    public ClazzOption getStudentCountData() {
        studentMapper.countStudentDegreeData();
        List<Map<String, Object>> list = studentMapper.countStudentData();
        List<Object> clazzList = list.stream().map(dateMap -> dateMap.get("clazzName")).toList();
        List<Object> dataList = list.stream().map(dateMap -> dateMap.get("num")).toList();
        return new ClazzOption(clazzList,dataList);
    }

}
